namespace CPlusPlusPlusPlus
{
    public class Car : IEquatable<Car>{
        public string Make { get; set; }
        public string Model { get; set; }
        public string Year { get; set; }

        public Car(string Year,string Model,string Make){
            this.Year=Year;
            this.Model= Model;
            this.Make=Make;
        }
        public Car(){
            this.Year="2000";
            this.Model= "3";
            this.Make="11";
        }

        // Implementation of IEquatable<T> interface
        public bool Equals(Car car)
        {
            return (this.Make, this.Model, this.Year) ==
                (car.Make, car.Model, car.Year);
        }

        public override string ToString()
        {
            return Year+"-"+Model+"-"+Make;
        }
    }

    public class IEquatableFunc
    {
        /*实现 IEquatable<T> 接口的任何类或结构都必须包含与该接口指定的签名匹配的 Equals 方法的定义。*/
        public static void Main(){
            Car car1 = new Car();
            Car car2 = new Car();
            Console.WriteLine(car1);
            Console.WriteLine(car1.Equals(car2));// true
            Console.WriteLine(ReferenceEquals(car1,car2));//false
        }
    }

    
}

//https://docs.microsoft.com/zh-cn/dotnet/csharp/fundamentals/types/interfaces